<template>
  <el-dialog
    :title="title"
    :visible="visible"
    width="30%"
    @close="onCloseDialog"
  >
    <slot name="body" />
    <span slot="footer" class="dialog-footer">
      <el-button class="del-btn" v-if="showDelete" type="danger" @click="() => onDelete.call($parent)">删除</el-button>
      <el-button type="primary" @click="() => onSubmit.call($parent)">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'BaseModifyDialog',
  props: {
    showDelete: {
      type: Boolean,
      required: true
    },
    title: {
      type: String,
      required: true
    },
    visible: {
      type: Boolean,
      required: true
    },
    onSubmit: {
      type: Function,
      required: true
    },
    onDelete: {
      type: Function,
      required: true
    },
    onCloseDialog: {
      type: Function,
      required: true
    }
  }
}
</script>

<style lang="scss">
  .del-btn {
    float: left;
  }
</style>
